package com.v0710.esbconver.runner;

import com.alibaba.excel.EasyExcel;
import com.v0710.esbconver.excel.ExcelData;
import com.v0710.esbconver.excel.ExcelReadListener;
import com.v0710.esbconver.config.ConfigExcel;
import org.apache.poi.openxml4j.util.ZipSecureFile;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

@Component
public class GenJavaFileRuner implements ApplicationRunner {

    @Autowired
    private ConfigExcel configExcel;


    @Override
    public void run(ApplicationArguments args) throws Exception {
        ZipSecureFile.setMinInflateRatio(-1.0d);
        ExcelReadListener excelReadListener = new ExcelReadListener(configExcel);
        for (String name : configExcel.getSheetName().split(",")) {
            EasyExcel.read(configExcel.getInterfaceFilePath(), ExcelData.class, excelReadListener).headRowNumber(0).sheet(name.split(":")[0]).doReadSync();
        }
    }
}
